home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet 2002 February / Practical Internet February 2002.iso / pc / Software / Browsing / httrack-3.09e2.exe / {app} / src / htsbase.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-07  |  3.8 KB  |  150 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20.  
  21. Important notes:
  22.  
  23. - We hereby ask people using this source NOT to use it in purpose of grabbing
  24. emails addresses, or collecting any other private information on persons.
  25. This would disgrace our work, and spoil the many hours we spent on it.
  26.  
  27.  
  28. Please visit our Website: http://www.httrack.com
  29. */
  30.  
  31.  
  32. /* ------------------------------------------------------------ */
  33. /* File: Basic definitions                                      */
  34. /*       Used in .c files for basic (malloc() ..) definitions   */
  35. /* Author: Xavier Roche                                         */
  36. /* ------------------------------------------------------------ */
  37.  
  38. #ifndef HTS_BASICH
  39. #define HTS_BASICH
  40.  
  41. #include "htsglobal.h"
  42.  
  43. // size_t et mode_t
  44. #include <stdio.h>
  45. #if HTS_WIN
  46. #else
  47. #include <fcntl.h>
  48. #endif
  49.  
  50. #if HTS_WIN
  51. #else
  52.  #define min(a,b) ((a)>(b)?(b):(a))
  53.  #define max(a,b) ((a)>(b)?(a):(b))
  54. #endif
  55.  
  56. // teste ΘgalitΘ de 2 chars, case insensitive
  57. #define hichar(a) ((((a)>='a') && ((a)<='z')) ? ((a)-('a'-'A')) : (a))
  58. #define streql(a,b) (hichar(a)==hichar(b))
  59.  
  60. // is this MIME an hypertext MIME (text/html), html/js-style or other script/text type?
  61. #define HTS_HYPERTEXT_DEFAULT_MIME "text/html"
  62. #define is_hypertext_mime(a) \
  63.    ( (strfield2((a),"text/html")!=0)\
  64.   || (strfield2((a),"application/x-javascript")!=0) \
  65.   || (strfield2((a),"text/css")!=0) \
  66.   /*|| (strfield2((a),"audio/x-pn-realaudio")!=0) */\
  67.   )
  68.  
  69. #define may_be_hypertext_mime(a) \
  70.    (\
  71.      (strfield2((a),"audio/x-pn-realaudio")!=0) \
  72.   )
  73.  
  74.  
  75. // caractΦre maj
  76. #define isUpperLetter(a) ( ((a) >= 'A') && ((a) <= 'Z') )
  77.  
  78. // conversion Θventuelle / vers antislash
  79. #if HTS_WIN
  80. char* antislash(char* s);
  81. #else
  82. #define antislash(A) (A)
  83. #endif
  84.  
  85.  
  86. // functions
  87. #if HTS_PLATFORM!=3
  88. #ifdef __cplusplus
  89. extern "C" {
  90. #endif
  91. #if HTS_PLATFORM!=2
  92. #if HTS_PLATFORM!=1
  93.  int   open      (const char *, int, ...);
  94. #endif
  95.  //int   read      (int,const char*,int);
  96.  //int   write     (int,char*,int);
  97. #endif
  98. #if HTS_PLATFORM!=1
  99.  int   close     (int);
  100.  void* calloc    (size_t,size_t);
  101.  void* malloc    (size_t);
  102.  void* realloc   (void*,size_t);
  103.  void  free      (void*);
  104. #endif
  105. #if HTS_WIN==0
  106.  void  bzero     (char*,unsigned int);
  107.  void  bcopy     (const char*,char*,unsigned int);
  108.  //int   strcasecmp(const char*,const char*);
  109. #endif
  110.  //int   strlen    (const char *);
  111. #if HTS_WIN
  112.  //int   mkdir     (const char*);
  113. #else
  114.  int   mkdir     (const char*,mode_t);
  115.  //int   isdigit   (char);
  116.  //int   isalpha   (char);
  117.  //int   isalnum   (char);
  118. #endif
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif
  123.  
  124.  
  125. #if HTS_WIN
  126. #define  bzero(a,b) memset(a,0,b)
  127. #define  bcopy(a,b,c) memcpy(b,a,c)
  128. #endif
  129.  
  130. // tracer malloc()
  131. #if HTS_TRACE_MALLOC
  132. #define malloct(A)    hts_malloc(A,0)
  133. #define calloct(A,B)  hts_malloc(A,B)
  134. #define freet(A)      hts_free(A)
  135. #define realloct(A,B) hts_realloc(A,B)
  136. void  hts_freeall();
  137. void* hts_malloc    (size_t,size_t);
  138. void  hts_free      (void*);
  139. void* hts_realloc   (void*,size_t);
  140. #else
  141. #define malloct(A)    malloc(A)
  142. #define calloct(A,B)  calloc(A,B)
  143. #define freet(A)      free(A)
  144. #define realloct(A,B) realloc(A,B)
  145. #endif
  146.  
  147.  
  148. #endif
  149.  
  150.